DEBUG		= -g
CCC		= g++ -Wall -O
CC		= gcc -ansi -Wall -O
CCFLAGS		= $(DEBUG)
CPPFLAGS	= -DTHREADS
LDFLAGS		= 
LIBS		= -lpthread

SRCS		= usim.cc misc.cc \
		  mc6809.cc mc6809in.cc \
		  mc6850.cc term.cc \
		  main.cc
OBJS		= $(SRCS:.cc=.o)
BIN		= usim

ifdef X11
SRCS            += mc6809_X.cc
LIBS		+= -L/usr/X11R6/lib -lX11
CPPFLAGS	+= -I/usr/X11R6/include -DX11
endif

all: $(BIN)

$(BIN):		$(OBJS)
	$(CCC) -o $(@) $(CCFLAGS) $(LDFLAGS) $(OBJS) $(LIBS)

.SUFFIXES:	.cc

.cc.o:
	$(CCC) $(CPPFLAGS) $(CCFLAGS) -c $<

$(OBJS):	machdep.h

machdep:	machdep.o
	$(CC) -o $(@) $(CCFLAGS) $(LDFLAGS) machdep.o

machdep.h:	machdep
	./machdep $(@)

clean:
	$(RM) -f machdep.h machdep.o machdep $(BIN) $(OBJS)

depend:		machdep.h
	makedepend $(SRCS)

# DO NOT DELETE THIS LINE -- make depend depends on it.
